LoadAssets();
function init(lvl) {

    
    setTimeout(function(){
        var canvasId = 'demoCanvas';
        canvas = document.getElementById(canvasId);

        var game = new Game('demoCanvas', lvl);
        externalAccessGame = game;
        var rc1;
        var rc2;
        var rc3;
        var rc4;
        var rc5;
        var rc6;
        var rc7;
        var rc8;
        
        var comNode1;
        var comNode2;
        var comNode3;
        var comNode4;
        var comNode5;
        var comNode6;
        var comNode7;
        var comNode8;
        var comNode9;
        
        switch (lvl){
            case '1':
                console.log("Jeu lancé en mode de difficulté FACILE.");
                
                rc3 = game.addResearchCenter(160, 350, 2, 15, 8);
                rc4 = game.addResearchCenter(750, 690, 2, 15, 8);
                rc7 = game.addResearchCenter(130, 630, 4, 15, 4);
                rc8 = game.addResearchCenter(875, 230, 4, 15, 4);

                comNode3 = game.addCommunicationNode(390, 340);
                comNode4 = game.addCommunicationNode(465, 480);
                comNode5 = game.addCommunicationNode(650, 400);
                comNode6 = game.addCommunicationNode(930, 575);
                
                game.addConnexion(comNode3, comNode4);
                game.addConnexion(comNode3, rc3);
                game.addConnexion(comNode4, comNode5);
                game.addConnexion(comNode4, rc7);
                game.addConnexion(comNode5, rc8);
                game.addConnexion(comNode5, comNode6);
                game.addConnexion(comNode6, rc4);
                
                break;
                
            case '2':
                console.log("Jeu lancé en mode de difficulté NORMAL.");

                rc3 = game.addResearchCenter(160, 350, 2, 15, 8);
                rc4 = game.addResearchCenter(750, 690, 2, 15, 8);
                rc5 = game.addResearchCenter(590, 245, 3, 15, 8);
                rc6 = game.addResearchCenter(100, 590, 3, 15, 8);
                rc7 = game.addResearchCenter(270, 505, 4, 15, 8);
                rc8 = game.addResearchCenter(875, 230, 4, 15, 8);

                comNode3 = game.addCommunicationNode(390, 340);
                comNode4 = game.addCommunicationNode(465, 480);
                comNode5 = game.addCommunicationNode(650, 400);
                comNode6 = game.addCommunicationNode(930, 575);
                comNode8 = game.addCommunicationNode(430, 660);
                
                game.addConnexion(comNode3, comNode4);
                game.addConnexion(comNode3, rc3);
                game.addConnexion(comNode4, comNode5);
                game.addConnexion(comNode4, comNode8);
                game.addConnexion(comNode5, rc5);
                game.addConnexion(comNode5, rc8);
                game.addConnexion(comNode5, comNode6);
                game.addConnexion(comNode5, comNode8);
                game.addConnexion(comNode8, rc6);
                game.addConnexion(comNode8, rc7);
                game.addConnexion(comNode6, rc4);
                
                break;
                
            case '3':
                console.log("Jeu lancé en mode de difficulté DIFFICILE.");
                
                rc1 = game.addResearchCenter(175, 80, 1, 10, 8);
                rc2 = game.addResearchCenter(555, 705, 1, 10, 8);
                rc3 = game.addResearchCenter(160, 350, 2, 10, 8);
                rc4 = game.addResearchCenter(750, 690, 2, 10, 8);
                rc5 = game.addResearchCenter(590, 245, 3, 10, 8);
                rc6 = game.addResearchCenter(100, 590, 3, 10, 8);
                rc7 = game.addResearchCenter(270, 505, 4, 10, 8);
                rc8 = game.addResearchCenter(875, 230, 4, 10, 8);

                comNode1 = game.addCommunicationNode(565, 80);
                comNode2 = game.addCommunicationNode(780, 285);
                comNode3 = game.addCommunicationNode(390, 340);
                comNode4 = game.addCommunicationNode(465, 480);
                comNode5 = game.addCommunicationNode(650, 400);
                comNode6 = game.addCommunicationNode(930, 575);
                comNode7 = game.addCommunicationNode(620, 550);
                comNode8 = game.addCommunicationNode(430, 660);
                comNode9 = game.addCommunicationNode(235, 672);
                
                game.addConnexion(comNode1, rc1);
                game.addConnexion(comNode1, comNode2);
                game.addConnexion(comNode1, comNode3);
                game.addConnexion(comNode3, comNode4);
                game.addConnexion(comNode3, rc3);
                game.addConnexion(comNode4, comNode5);
                game.addConnexion(comNode4, comNode7);
                game.addConnexion(comNode4, comNode8);
                game.addConnexion(comNode2, rc8);
                game.addConnexion(comNode5, rc5);
                game.addConnexion(comNode2, comNode5);
                game.addConnexion(comNode5, comNode6);
                game.addConnexion(comNode7, rc2);
                game.addConnexion(comNode7, comNode8);
                game.addConnexion(comNode8, comNode9);
                game.addConnexion(comNode8, rc7);
                game.addConnexion(comNode9, rc6);
                game.addConnexion(comNode6, rc4);

                
                break;
        }
        
        game.start();
    }, 3000);

}
